home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / system / mail / transpor / ifmail23.z / ifmail23 / ifmail / ifgate / iftoss.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-09  |  1.5 KB  |  87 lines

  1. #include <sys/types.h>
  2. #include <unistd.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <sys/stat.h>
  6. #include <string.h>
  7. #ifdef HAS_SYSLOG
  8. #include <syslog.h>
  9. #endif
  10. #include "getopt.h"
  11. #include "lutil.h"
  12. #include "config.h"
  13. #include "version.h"
  14. #include "ftn.h"
  15. #include "getheader.h"
  16.  
  17. extern int getmessage(FILE *,faddr *,faddr *);
  18. extern void readareas(char *);
  19. extern void readalias(char *);
  20.  
  21. extern int num_echo,num_mail;
  22.  
  23. int usetmp=1; /* to tell bgets that we do not use batch mode */
  24.  
  25. void usage(name)
  26. char *name;
  27. {
  28.     confusage("");
  29. }
  30.  
  31. FILE *nb = NULL;
  32.  
  33. int main(argc,argv)
  34. int argc;
  35. char *argv[];
  36. {
  37.     int c;
  38.     int rc;
  39.     faddr from,to;
  40.  
  41. #ifdef MAILLOG
  42.     logfacility=MAILLOG;
  43. #endif
  44.  
  45.     setmyname(argv[0]);
  46.     while ((c=getopt(argc,argv,"hx:I:")) != -1)
  47.     if (confopt(c,optarg)) switch (c)
  48.     {
  49.         default:    usage(argv[0]); exit(1);
  50.     }
  51.  
  52.     if (readconfig())
  53.     {
  54.         logerr("Error getting configuration, aborting");
  55.         exit(1);
  56.     }
  57.  
  58.     readareas(areafile);
  59.     readalias(aliasfile);
  60.  
  61.     if (verbose)
  62.     {
  63.         mkdir("/tmp/ifmail",0777);
  64.         loginf("in debug mode resultant messages will go to /tmp/ifmail");
  65.     }
  66.  
  67. #ifdef PARANOID
  68.     if ((rc=getheader(&from,&to,stdin)) != 0)
  69. #else
  70.     if (((rc=getheader(&from,&to,stdin)) != 0) && (rc != 4))
  71. #endif
  72.     {
  73.         logerr("%s, aborting",(rc==3)?"packet not to this node":
  74.             (rc==4)?"bad password":"bad packet");
  75.         exit(rc);
  76.     }
  77.  
  78.     while ((rc=getmessage(stdin,&from,&to)) == 1);
  79.  
  80.     if (nb) fclose(nb);
  81.  
  82.     loginf("end %d echomail, %d netmail messages processed, rc=%d",
  83.         num_echo,num_mail,rc);
  84.  
  85.     return rc;
  86. }
  87.